package componentes.crud;

import componentes.Tabla;
import java.awt.event.ActionEvent;
import java.util.List;
import javax.swing.AbstractAction;
import modelos.Alumno;
import org.jdesktop.beansbinding.BindingGroup;

/**
 *
 * @author user
 */
public class nuevoAction extends AbstractAction{
    private BindingGroup bindingGroup;
    private List lst;
    private Tabla tbl;

    public nuevoAction() {
        putValue(NAME, "Nuevo");
        putValue(SHORT_DESCRIPTION, "Nuevo Elemento");
        
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        getBindingGroup().getBinding("tabla").unbind();
        getLst().add(new Alumno()); 
        getBindingGroup().getBinding("tabla").bind();
        int row = getLst().size()-1;
        getTbl().setRowSelectionInterval(row, row);
        getTbl().scrollRectToVisible(getTbl().getCellRect(row, 0, true));
        getTbl().repaint();
    }

    /**
     * @return the bindingGroup
     */
    public BindingGroup getBindingGroup() {
        return bindingGroup;
    }

    /**
     * @param bindingGroup the bindingGroup to set
     */
    public void setBindingGroup(BindingGroup bindingGroup) {
        this.bindingGroup = bindingGroup;
    }

    /**
     * @return the lst
     */
    public List getLst() {
        return lst;
    }

    /**
     * @param lst the lst to set
     */
    public void setLst(List lst) {
        this.lst = lst;
    }

    /**
     * @return the tbl
     */
    public Tabla getTbl() {
        return tbl;
    }

    /**
     * @param tbl the tbl to set
     */
    public void setTbl(Tabla tbl) {
        this.tbl = tbl;
    }
    
    
}
